﻿<phone:PhoneApplicationPage x:Class="Strava1.SegmentDetails"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:tk="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            xmlns:map="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
                            xmlns:mapCore="clr-namespace:Microsoft.Phone.Controls.Maps.Core;assembly=Microsoft.Phone.Controls.Maps"
                            xmlns:local="clr-namespace:Strava1"
                            mc:Ignorable="d"
                            d:DesignWidth="480"
                            d:DesignHeight="768"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait"
                            shell:SystemTray.IsVisible="True">
    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator IsIndeterminate="{Binding Busy}"
                                 IsVisible="{Binding Busy}"
                                 Text="{Binding BusyMessage}" />
    </shell:SystemTray.ProgressIndicator>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot"
          Background="Transparent">
        <!--Pivot Control-->
        <controls:Pivot Title="{Binding Name, StringFormat='STRAVA VIEWER - {0}'}">
            <controls:Pivot.Background>
                <ImageBrush ImageSource="SplashScreenImage2.png"
                            Opacity="0.75" />
            </controls:Pivot.Background>
            <!--Pivot item one-->
            <controls:PivotItem Header="leaderboard">
                <ListBox ItemsSource="{Binding Efforts}"
                         tk:TiltEffect.IsTiltEnabled="True">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="12,0,0,10">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <TextBlock Text="{Binding OverallPlacing}"
                                           FontSize="{StaticResource PhoneFontSizeExtraLarge}"
                                           Width="55"
                                           Grid.RowSpan="3" />
                                <TextBlock Text="{Binding Athlete.Name}"
                                           FontSize="{StaticResource PhoneFontSizeMedium}"
                                           Grid.Column="1"
                                           Grid.ColumnSpan="2" />
                                <TextBlock Text="{Binding VAM, StringFormat='{0:n0}'}"
                                           Grid.Column="3"
                                           HorizontalAlignment="Right"
                                           FontSize="{StaticResource PhoneFontSizeMedium}"/>
                                <TextBlock Text="{Binding ElapsedTime, Converter={StaticResource SecondsToTimeConverter}}"
                                           Foreground="{StaticResource PhoneSubtleBrush}"
                                           Grid.Row="1"
                                           Grid.Column="1" />
                                <TextBlock Text="{Binding StartDate, StringFormat='{}{0:d}'}"
                                           Foreground="{StaticResource PhoneSubtleBrush}"
                                           HorizontalAlignment="Center"
                                           Grid.Row="1"
                                           Grid.Column="2" />
                                <TextBlock Text="{Binding AverageSpeed, StringFormat='{}{0:n1}mph'}"
                                           Foreground="{StaticResource PhoneSubtleBrush}"
                                           HorizontalAlignment="Right"
                                           Grid.Row="1"
                                           Grid.Column="3" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>

            <controls:PivotItem Header="my results">
                <ListBox DataContext="{Binding MyEffortsCVS}"
                         ItemsSource="{Binding}"
                         tk:TiltEffect.IsTiltEnabled="True"
                         SelectionChanged="MyEfforts_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="12,0,0,10">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <TextBlock Text="{Binding OverallPlacing}"
                                           FontSize="{StaticResource PhoneFontSizeExtraLarge}"
                                           Width="55"
                                           Grid.RowSpan="3" />
                                <TextBlock Text="{Binding Ride.Name}"
                                           TextWrapping="Wrap"
                                           FontSize="{StaticResource PhoneFontSizeMedium}"
                                           Grid.Column="1"
                                           Grid.ColumnSpan="3" />
                                <TextBlock Text="{Binding ElapsedTime, Converter={StaticResource SecondsToTimeConverter}}"
                                           Foreground="{StaticResource PhoneSubtleBrush}"
                                           Grid.Row="1"
                                           Grid.Column="1" />
                                <TextBlock Text="{Binding StartDate, StringFormat='{}{0:d}'}"
                                           Foreground="{StaticResource PhoneSubtleBrush}"
                                           HorizontalAlignment="Center"
                                           Grid.Row="1"
                                           Grid.Column="2" />
                                <TextBlock Text="{Binding AverageSpeed, StringFormat='{}{0:n1}mph'}"
                                           Foreground="{StaticResource PhoneSubtleBrush}"
                                           HorizontalAlignment="Right"
                                           Grid.Row="1"
                                           Grid.Column="3" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>

            <!--Pivot item two-->
            <controls:PivotItem Header="map">
                <Grid>
                    <map:Map Margin="0,10"
                             ZoomLevel="{Binding ZoomLevel}"
                             x:Name="myMap"
                             Center="{Binding MapCenter}"
                             Grid.ColumnSpan="3"
                             CredentialsProvider="AoOAVXaPhN9YePJC_ptD_S4M42CEVLKGJ4lxiIksAOBaPdJtE6havx99boLZn9G8"
                             CopyrightVisibility="Collapsed"
                             LogoVisibility="Collapsed">
                        <map:Map.Mode>
                            <mapCore:MercatorMode />
                        </map:Map.Mode>
                        <map:Map.Children>
                            <map:MapTileLayer>
                                <map:MapTileLayer.TileSources>
                                    <local:OpenCycleMap />
                                </map:MapTileLayer.TileSources>
                            </map:MapTileLayer>
                            <map:MapLayer>
                                <map:MapPolyline Stroke="#892700"
                                                 StrokeThickness="4"
                                                 Locations="{Binding Locations}" />
                            </map:MapLayer>
                        </map:Map.Children>
                    </map:Map>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="Refresh" Text="Refresh" Click="Refresh_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>